package dao.hikari;

import com.zaxxer.hikari.HikariConfig;
import constants.DbConstants;

import javax.sql.DataSource;

/**
 * Hikari数据源单例
 */
public class HikariDataSourceInstance {

    private static com.zaxxer.hikari.HikariDataSource dataSource = null;

    public static DataSource getHikariDataSource() {
        if (dataSource == null) {
            synchronized (HikariDataSourceInstance.class) {
                if (dataSource == null) {
                    HikariConfig config = new HikariConfig(DbConstants.properties);
                    dataSource = new com.zaxxer.hikari.HikariDataSource(config);
                }
            }
        }
        return dataSource;
    }
}
